

  //签名交易

//var bitcore = require('bitcore-lib')
var bitcoin = require('bitcoinjs-lib')

var network = bitcoin.networks.testnet
//notice input的交易id  必须用input对应地址的私钥签名  
   var wif = 'cT8aGHWUkYbCZnmFqRTe1vsp48BRb23vRJ6asnv8799r4JXGzbAi'          //myEguG6rkneMk3AHfZyDfHQvFc6xG9wdCH

   var alice = bitcoin.ECPair.fromWIF(wif,network)
    console.log(alice.getAddress())
    var txb = new bitcoin.TransactionBuilder(network)

    txb.setVersion(1)
    txb.addInput('7f0620b39e5552660c1f993769c9664ebf3661e435bf9d9944320b1aac3e0f7a', 0) //0.01859-0.0001
    txb.addOutput('mxsQmW8AiifZfGpRuh5ZRkonsjo8eWaUAp', 1058000)
    

    txb.sign(0, alice)
    console.log(txb.build().toHex())

//GatAUjMkNAg63YfDVEEH82KR37cXk88ZXb
//E56wEHynZwUTsZJjpoCXkkCcTRGzDvnMTZdf8P8n1DJqe2e9XkqG

